<!DOCTYPE html><html lang="en" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>【Activiti7】工作流使用 | ChenWeiHui's Blog</title><meta name="author" content="cwh"><meta name="copyright" content="cwh"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="概述ctiviti是一个工作流引警，activiti可以将业务系统中复杂的业务流程抽取出来，使用专门的建模语言BPMN2.0进行定义，业务流程按照预先定义的流程进行执行，实现了系统的流程由activiti进行管理，减少业务系统由于流程变更进行系统升级改造的工作量，从而提高系统的健壮性，同时也减少了系统开发维护成本。 表结构   表分类 表名 解释    一般数据      [ACT_GE_BYTE">
<meta property="og:type" content="article">
<meta property="og:title" content="【Activiti7】工作流使用">
<meta property="og:url" content="https://gitee.com/CWH6/2023/12/21/%E3%80%90Activiti7%E3%80%91%E5%B7%A5%E4%BD%9C%E6%B5%81%E4%BD%BF%E7%94%A8/index.html">
<meta property="og:site_name" content="ChenWeiHui&#39;s Blog">
<meta property="og:description" content="概述ctiviti是一个工作流引警，activiti可以将业务系统中复杂的业务流程抽取出来，使用专门的建模语言BPMN2.0进行定义，业务流程按照预先定义的流程进行执行，实现了系统的流程由activiti进行管理，减少业务系统由于流程变更进行系统升级改造的工作量，从而提高系统的健壮性，同时也减少了系统开发维护成本。 表结构   表分类 表名 解释    一般数据      [ACT_GE_BYTE">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://cwh6-bucket.oss-cn-shanghai.aliyuncs.com/bk/xhs.png">
<meta property="article:published_time" content="2023-12-21T13:21:01.000Z">
<meta property="article:modified_time" content="2023-12-21T13:27:05.270Z">
<meta property="article:author" content="cwh">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cwh6-bucket.oss-cn-shanghai.aliyuncs.com/bk/xhs.png"><link rel="shortcut icon" href="/bk/img/jljy3.png"><link rel="canonical" href="https://gitee.com/CWH6/2023/12/21/%E3%80%90Activiti7%E3%80%91%E5%B7%A5%E4%BD%9C%E6%B5%81%E4%BD%BF%E7%94%A8/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/bk/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/bk/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '【Activiti7】工作流使用',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-12-21 21:27:05'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.2"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://cwh6-bucket.oss-cn-shanghai.aliyuncs.com/bk/xhs.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/bk/archives/"><div class="headline">Articles</div><div class="length-num">66</div></a><a href="/bk/tags/"><div class="headline">Tags</div><div class="length-num">33</div></a><a href="/bk/categories/"><div class="headline">Categories</div><div class="length-num">8</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/bk/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/bk/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/bk/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/bk/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/bk/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/bk/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/bk/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/bk/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/bk/img/alone_blue_sky.jpg')"><nav id="nav"><span id="blog-info"><a href="/bk/" title="ChenWeiHui's Blog"><span class="site-name">ChenWeiHui's Blog</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/bk/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/bk/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/bk/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/bk/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/bk/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/bk/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/bk/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/bk/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">【Activiti7】工作流使用</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">Created</span><time class="post-meta-date-created" datetime="2023-12-21T13:21:01.000Z" title="Created 2023-12-21 21:21:01">2023-12-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">Updated</span><time class="post-meta-date-updated" datetime="2023-12-21T13:27:05.270Z" title="Updated 2023-12-21 21:27:05">2023-12-21</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="【Activiti7】工作流使用"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">Post View:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="概述"><a href="#概述" class="headerlink" title="概述"></a>概述</h2><p>ctiviti是一个工作流引警，activiti可以将<strong>业务系统中复杂的业务流程抽取出来</strong>，使用专门的<strong>建模语言BPMN2.0进行定义</strong>，<strong>业务流程按照预先定义的流程进行执行</strong>，实现了系统的流程由activiti进行管理，减少业务系统由于流程变更进行系统升级改造的工作量，<strong>从而提高系统的健壮性，同时也减少了系统开发维护成本。</strong></p>
<h2 id="表结构"><a href="#表结构" class="headerlink" title="表结构"></a>表结构</h2><table>
<thead>
<tr>
<th>表分类</th>
<th>表名</th>
<th>解释</th>
</tr>
</thead>
<tbody><tr>
<td>一般数据</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>[ACT_GE_BYTEARRAY]</td>
<td>通用的流程定义和流程资源</td>
</tr>
<tr>
<td></td>
<td>[ACT_GE_PROPERTY]</td>
<td>系统相关属性</td>
</tr>
<tr>
<td>流程历史记录</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>[ACT_HI_ACTINST]</td>
<td>历史的流程实例</td>
</tr>
<tr>
<td></td>
<td>[ACT_HI_ATTACHMENT]</td>
<td>历史的流程附件</td>
</tr>
<tr>
<td></td>
<td>[ACT_HI_COMMENT]</td>
<td>历史的说明性信息</td>
</tr>
<tr>
<td></td>
<td>[ACT_HI_DETAIL]</td>
<td>历史的流程运行中的细节信息</td>
</tr>
<tr>
<td></td>
<td>[ACT_HI_IDENTITYLINKJ</td>
<td>历史的流程运行过程中用户关系</td>
</tr>
<tr>
<td></td>
<td>[ACT_HI_PROCINST]</td>
<td>历史的流程实例</td>
</tr>
<tr>
<td></td>
<td>[ACT_HI_TASKINST]</td>
<td>历史的任务实例</td>
</tr>
<tr>
<td></td>
<td>[ACT_HI_VARINST]</td>
<td>历史的流程运行中的变量信息</td>
</tr>
<tr>
<td>流程定义表</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>[ACT_RE_DEPLOYMENT]</td>
<td>部署单元信息</td>
</tr>
<tr>
<td></td>
<td>[ACT_RE_MODEL]</td>
<td>模型信息</td>
</tr>
<tr>
<td></td>
<td>[ACT_RE_PROCDEF]</td>
<td>已部署的流程定义</td>
</tr>
<tr>
<td>运行实例表</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>[ACT_RU_EVENT_SUBSCR]</td>
<td>运行时事件</td>
</tr>
<tr>
<td></td>
<td>[ACT_RU_EXECUTION]</td>
<td>运行时流程执行实例</td>
</tr>
<tr>
<td></td>
<td>[ACT_RU_IDENTITYLINKJ</td>
<td>运行时用户关系信息，存储任务节点与参与者的相关信息</td>
</tr>
<tr>
<td></td>
<td>[ACT_RU_JOB]</td>
<td>运行时作业</td>
</tr>
<tr>
<td></td>
<td>[ACT_RU_TASK]</td>
<td>运行时任务</td>
</tr>
<tr>
<td></td>
<td>[ACT_RU_VARIABLE]</td>
<td>运行时变量表</td>
</tr>
</tbody></table>
<h2 id="类关系"><a href="#类关系" class="headerlink" title="类关系"></a>类关系</h2><table>
<thead>
<tr>
<th>类</th>
<th>作用</th>
</tr>
</thead>
<tbody><tr>
<td>ProcessEngine</td>
<td>调用上面其他服务： RepositoryService,TaskService….</td>
</tr>
<tr>
<td>RepositoryService</td>
<td>操作跟 部署 相关的表，操作 re 表</td>
</tr>
<tr>
<td>RuntimeService</td>
<td>操作跟 运行 相关的表，操作 ru 表</td>
</tr>
<tr>
<td>HistoryService</td>
<td>操作跟 历史 相关的表，操作 hi 表</td>
</tr>
</tbody></table>
<h2 id="流程部署"><a href="#流程部署" class="headerlink" title="流程部署"></a>流程部署</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">* 测试流程部署</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"><span class="meta">@Test</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">testDeployment</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="comment">// 1、创建 ProcessEngine</span></span><br><span class="line">    <span class="type">ProcessEngine</span> <span class="variable">processEngine</span> <span class="operator">=</span> ProcessEngines.getDefaultProcessEngine();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 2、获取 RepositoryService</span></span><br><span class="line">    <span class="type">RepositoryService</span> <span class="variable">repositoryService</span> <span class="operator">=</span> processEngine.getRepositoryService();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 3、使用 service 进行流程的部署</span></span><br><span class="line">    <span class="type">Deployment</span> <span class="variable">deployment</span> <span class="operator">=</span> repositoryService.createDeployment()</span><br><span class="line">            .name(<span class="string">&quot;出差申请流程&quot;</span>)</span><br><span class="line">            .addClasspathResource(<span class="string">&quot;bpmn/evection.bpmn&quot;</span>) <span class="comment">// 添加 BPMN 文件</span></span><br><span class="line">            .addClasspathResource(<span class="string">&quot;bpmn/evection.png&quot;</span>)  <span class="comment">// 添加流程图 PNG 文件</span></span><br><span class="line">            .deploy();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 4、输出部署信息</span></span><br><span class="line">    System.out.println(<span class="string">&quot;流程部署ID: &quot;</span> + deployment.getId()); <span class="comment">//</span></span><br><span class="line">    System.out.println(<span class="string">&quot;流程部署名称: &quot;</span> + deployment.getName()); <span class="comment">//出差申请流程</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h2 id="启动流程实例"><a href="#启动流程实例" class="headerlink" title="启动流程实例"></a>启动流程实例</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">testStartProcess</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="comment">// 1. 创建ProcessEngine</span></span><br><span class="line">    <span class="type">ProcessEngine</span> <span class="variable">processEngine</span> <span class="operator">=</span> ProcessEngines.getDefaultProcessEngine();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 2. 获取RuntimeService</span></span><br><span class="line">    <span class="type">RuntimeService</span> <span class="variable">runtimeService</span> <span class="operator">=</span> processEngine.getRuntimeService();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 3. 根据流程定义的key启动流程实例</span></span><br><span class="line">    <span class="type">ProcessInstance</span> <span class="variable">instance</span> <span class="operator">=</span> runtimeService.startProcessInstanceByKey(<span class="string">&quot;myEvection&quot;</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 4. 输出信息</span></span><br><span class="line">    System.out.println(<span class="string">&quot;流程定义ID: &quot;</span> + instance.getProcessDefinitionId());<span class="comment">// myEvection: 1:4</span></span><br><span class="line">    System.out.println(<span class="string">&quot;流程实例ID: &quot;</span> + instance.getId()); <span class="comment">// 2501 </span></span><br><span class="line">    System.out.println(<span class="string">&quot;当前活动的ID: &quot;</span> + instance.getActivityId()); <span class="comment">// null</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h2 id="查看执行任务"><a href="#查看执行任务" class="headerlink" title="查看执行任务"></a>查看执行任务</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">testFindPersonalTaskList</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="comment">// 1. 获取流程引擎</span></span><br><span class="line">    <span class="type">ProcessEngine</span> <span class="variable">processEngine</span> <span class="operator">=</span> ProcessEngines.getDefaultProcessEngine();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 2. 获取TaskService</span></span><br><span class="line">    <span class="type">TaskService</span> <span class="variable">taskService</span> <span class="operator">=</span> processEngine.getTaskService();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 3. 根据流程Key和任务的负责人查询任务</span></span><br><span class="line">    List&lt;Task&gt; taskList = taskService.createTaskQuery()</span><br><span class="line">            .processDefinitionKey(<span class="string">&quot;myEvection&quot;</span>) <span class="comment">// 要查询的流程定义Key</span></span><br><span class="line">            .taskAssignee(<span class="string">&quot;zhangsan&quot;</span>) <span class="comment">// 要查询的负责人</span></span><br><span class="line">            .list();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 4. 输出任务信息</span></span><br><span class="line">    <span class="keyword">for</span> (Task task : taskList) &#123;</span><br><span class="line">        System.out.println(<span class="string">&quot;流程实例id=&quot;</span> + task.getProcessInstanceId());</span><br><span class="line">        System.out.println(<span class="string">&quot;任务Id=&quot;</span> + task.getId());</span><br><span class="line">        System.out.println(<span class="string">&quot;任务负责人=&quot;</span> + task.getAssignee());</span><br><span class="line">        System.out.println(<span class="string">&quot;任务名称=&quot;</span> + task.getName());</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h2 id="发起申请"><a href="#发起申请" class="headerlink" title="发起申请"></a>发起申请</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">completeTask</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="comment">// 获取流程引擎</span></span><br><span class="line">    <span class="type">ProcessEngine</span> <span class="variable">processEngine</span> <span class="operator">=</span> ProcessEngines.getDefaultProcessEngine();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 获取TaskService</span></span><br><span class="line">    <span class="type">TaskService</span> <span class="variable">taskService</span> <span class="operator">=</span> processEngine.getTaskService();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 根据任务id完成任务</span></span><br><span class="line">    <span class="type">String</span> <span class="variable">taskId</span> <span class="operator">=</span> <span class="string">&quot;2505&quot;</span>; <span class="comment">// 请替换为您要完成的任务ID</span></span><br><span class="line">    taskService.complete(taskId);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h2 id="上级审批"><a href="#上级审批" class="headerlink" title="上级审批"></a>上级审批</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">completeTask</span><span class="params">()</span> &#123;</span><br><span class="line">    <span class="comment">// 获取引擎</span></span><br><span class="line">    <span class="type">ProcessEngine</span> <span class="variable">processEngine</span> <span class="operator">=</span> ProcessEngines.getDefaultProcessEngine();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 获取操作任务的服务 TaskService</span></span><br><span class="line">    <span class="type">TaskService</span> <span class="variable">taskService</span> <span class="operator">=</span> processEngine.getTaskService();</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 完成任务，参数：任务id，完成zhangsan的任务</span></span><br><span class="line">    taskService.complete(<span class="string">&quot;2505&quot;</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 获取jerry-myEvection对应的任务</span></span><br><span class="line">    <span class="type">Task</span> <span class="variable">task</span> <span class="operator">=</span> taskService.createTaskQuery()</span><br><span class="line">            .processDefinitionKey(<span class="string">&quot;myEvection&quot;</span>)</span><br><span class="line">            .taskAssignee(<span class="string">&quot;jerry&quot;</span>)  <span class="comment">//经理名字   后续修改这个完成其他人多的审批任务</span></span><br><span class="line">            .singleResult();</span><br><span class="line"></span><br><span class="line">    System.out.println(<span class="string">&quot;流程实例id=&quot;</span> + task.getProcessInstanceId());</span><br><span class="line">    System.out.println(<span class="string">&quot;任务Id=&quot;</span> + task.getId());</span><br><span class="line">    System.out.println(<span class="string">&quot;任务负责人=&quot;</span> + task.getAssignee());</span><br><span class="line">    System.out.println(<span class="string">&quot;任务名称=&quot;</span> + task.getName());</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 完成jerry的任务</span></span><br><span class="line">    taskService.complete(task.getId());</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">Author: </span><span class="post-copyright-info"><a href="https://gitee.com/CWH6">cwh</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">Link: </span><span class="post-copyright-info"><a href="https://gitee.com/CWH6/2023/12/21/%E3%80%90Activiti7%E3%80%91%E5%B7%A5%E4%BD%9C%E6%B5%81%E4%BD%BF%E7%94%A8/">https://gitee.com/CWH6/2023/12/21/%E3%80%90Activiti7%E3%80%91%E5%B7%A5%E4%BD%9C%E6%B5%81%E4%BD%BF%E7%94%A8/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">Copyright Notice: </span><span class="post-copyright-info">All articles in this blog are licensed under <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> unless stating additionally.</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://cwh6-bucket.oss-cn-shanghai.aliyuncs.com/bk/xhs.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/bk/2023/12/21/%E3%80%90%E5%8C%BA%E5%9D%97%E9%93%BE%E3%80%91%E4%BB%A5%E5%A4%AA%E5%9D%8A%E6%99%BA%E8%83%BD%E5%90%88%E7%BA%A6/" title="【区块链】以太坊智能合约"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">Previous Post</div><div class="prev_info">【区块链】以太坊智能合约</div></div></a></div><div class="next-post pull-right"><a href="/bk/2023/11/11/%E3%80%90cas%E3%80%91%E5%8D%95%E7%82%B9%E7%99%BB%E9%99%86/" title="【cas】单点登陆"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">Next Post</div><div class="next_info">【cas】单点登陆</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://cwh6-bucket.oss-cn-shanghai.aliyuncs.com/bk/xhs.png" onerror="this.onerror=null;this.src='/bk/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">cwh</div><div class="author-info__description">新博客地址：http://cwh6.gitee.io/vuepressv2/</div></div><div class="card-info-data site-data is-center"><a href="/bk/archives/"><div class="headline">Articles</div><div class="length-num">66</div></a><a href="/bk/tags/"><div class="headline">Tags</div><div class="length-num">33</div></a><a href="/bk/categories/"><div class="headline">Categories</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="mailto:2747758546@qq.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a><a class="social-icon" href="https://cwh6-bucket.oss-cn-shanghai.aliyuncs.com/bk/wx_self.jpg" target="_blank" title="wx"><i class="fas fa-qq" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>Announcement</span></div><div class="announcement_content">ありがとう、私の暗い世界の小さな太陽、ありがとう、ずっと温めてくれた</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>Catalog</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%A6%82%E8%BF%B0"><span class="toc-number">1.</span> <span class="toc-text">概述</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%A1%A8%E7%BB%93%E6%9E%84"><span class="toc-number">2.</span> <span class="toc-text">表结构</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%B1%BB%E5%85%B3%E7%B3%BB"><span class="toc-number">3.</span> <span class="toc-text">类关系</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B5%81%E7%A8%8B%E9%83%A8%E7%BD%B2"><span class="toc-number">4.</span> <span class="toc-text">流程部署</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%90%AF%E5%8A%A8%E6%B5%81%E7%A8%8B%E5%AE%9E%E4%BE%8B"><span class="toc-number">5.</span> <span class="toc-text">启动流程实例</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E6%89%A7%E8%A1%8C%E4%BB%BB%E5%8A%A1"><span class="toc-number">6.</span> <span class="toc-text">查看执行任务</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%91%E8%B5%B7%E7%94%B3%E8%AF%B7"><span class="toc-number">7.</span> <span class="toc-text">发起申请</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8A%E7%BA%A7%E5%AE%A1%E6%89%B9"><span class="toc-number">8.</span> <span class="toc-text">上级审批</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/bk/2024/02/05/SpringIOC%E7%9A%84%E7%90%86%E8%A7%A3/" title="SpringIOC的理解">SpringIOC的理解</a><time datetime="2024-02-05T14:26:55.000Z" title="Created 2024-02-05 22:26:55">2024-02-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/bk/2024/01/18/%E3%80%90ai%E3%80%91chatgpt%E7%BB%95%E5%BC%80%E6%A3%80%E6%9F%A5%E8%BF%87%E6%BB%A4/" title="【ai】chatgpt绕开检查过滤">【ai】chatgpt绕开检查过滤</a><time datetime="2024-01-18T15:55:53.000Z" title="Created 2024-01-18 23:55:53">2024-01-18</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/bk/2024/01/15/%E3%80%90ai%E6%A8%A1%E5%9E%8B%E3%80%91%E5%88%A4%E6%96%AD%E8%AF%AD%E5%8F%A5%E7%9A%84%E7%A7%AF%E6%9E%81%E6%80%A7%E4%B8%8E%E6%B6%88%E6%9E%81%E6%80%A7/" title="【ai模型】判断语句的积极性与消极性">【ai模型】判断语句的积极性与消极性</a><time datetime="2024-01-15T13:10:14.000Z" title="Created 2024-01-15 21:10:14">2024-01-15</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/bk/2023/12/21/%E3%80%90%E5%8C%BA%E5%9D%97%E9%93%BE%E3%80%91%E4%BB%A5%E5%A4%AA%E5%9D%8A%E6%99%BA%E8%83%BD%E5%90%88%E7%BA%A6/" title="【区块链】以太坊智能合约">【区块链】以太坊智能合约</a><time datetime="2023-12-21T13:36:30.000Z" title="Created 2023-12-21 21:36:30">2023-12-21</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/bk/2023/12/21/%E3%80%90Activiti7%E3%80%91%E5%B7%A5%E4%BD%9C%E6%B5%81%E4%BD%BF%E7%94%A8/" title="【Activiti7】工作流使用">【Activiti7】工作流使用</a><time datetime="2023-12-21T13:21:01.000Z" title="Created 2023-12-21 21:21:01">2023-12-21</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By cwh</div><div class="framework-info"><span>Framework </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>Theme </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="Read Mode"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="Switch Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="Table Of Contents"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="Back To Top"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/bk/js/utils.js"></script><script src="/bk/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-show-text.min.js" data-mobile="false" data-text="offer" data-fontsize="15px" data-random="false" async="async"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>